<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/1/16
 * Time: 15:03
 */

namespace lib;

class Email
{
    protected $email = null;

    public function __construct()
    {
        $smtp = new Smtp();
        $smtpserver = "smtp.mxhichina.com";//SMTP服务器
        $smtpserverport =25;//SMTP服务器端口
        $smtpuser = 'lx@ichunt.com';//SMTP服务器的用户帐号
        $smtppass = "IChunt2016";//SMTP服务器的用户密码
        $smtp->debug = false;//是否显示发送的调试信息
        $smtp->smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);//这里面的一个true是表示使用身份验证,否则不使用身份验证.
        $this->email = $smtp;
    }

    /**
     * 发送邮件
     * @param $toemail
     * @param $title
     * @param $content
     * @return mixed
     */
    public function send($toemail, $title, $content)
    {
        $smtpusermail = "lx@ichunt.com";//SMTP服务器的用户邮箱
        $smtpemailto = $toemail;//发送给谁
        $mailname = '猎芯网';
        $mailtitle = $title;//邮件主题
        $mailcontent = $content;//邮件内容
        $mailtype = "HTML";//邮件格式（HTML/TXT）,TXT为文本邮件
        //************************ 配置信息 ****************************
        $state = $this->email->sendmail($smtpemailto, $smtpusermail, $mailtitle, $mailcontent, $mailtype,$mailname);
        return $state;
    }
}